<!--项目启动--合同登记-->
<template>
  <div style="background: #f5f5f5">
    <div class="contract-content">
      <div class="card-title">合同登记</div>
      <div class="contract-card">
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="card-row-container" @click="showModalPage('收款合同')">
              <div class="left-icon bg-blue"><i class="el-icon-edit" style="font-size: 28px;color: #FFF;"></i></div>
              <div class="rightTitle">
                <div class="mainTitle">收款合同</div>
                <div class="subTitle">登记已签约完成的收款合同</div>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="card-row-container" @click="showModalPage('付款合同')">
              <div class="left-icon bg-yellow"><i class="el-icon-document" style="font-size: 28px;color: #FFF;"></i>
              </div>
              <div class="rightTitle">
                <div class="mainTitle">付款合同</div>
                <div class="subTitle">登记已签约完成的付款合同</div>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="contract-content">
      <div class="card-title">合同档案</div>
      <div class="top-search">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
          <el-form-item label="项目名称" prop="entryName">
            <el-input
              v-model="queryParams.entryName"
              placeholder="请输入项目名称"
              clearable
            />
          </el-form-item>
          <el-form-item label="合同名称" prop="contractName">
            <el-input
              v-model="queryParams.contractName"
              placeholder="请输入合同名称"
              clearable
            />
          </el-form-item>
          <el-form-item label="合同编号" prop="contractNumber">
            <el-input
              v-model="queryParams.contractNumber"
              placeholder="请输入合同编号"
              clearable
            />
          </el-form-item>
          <el-form-item label="收付类型" prop="paymentType">
            <el-select v-model="queryParams.paymentType" placeholder="收付类型" clearable>
              <el-option
                v-for="item in paymentTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="相对方" prop="facingEachOther">
            <el-input
              v-model="queryParams.facingEachOther"
              placeholder="请输入相对方"
              clearable
            />
          </el-form-item>
          <el-form-item style="float: right">
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            <a :style="{ marginLeft: '8px', fontSize: '12px' }" @click="toggle">
              {{ expand ? '折叠' : '展开' }}
              <i class="el-icon-arrow-up" v-if="expand"></i>
              <i class="el-icon-arrow-down" v-if="!expand"></i>
            </a>
          </el-form-item>
        </el-form>
      </div>
      <div class="bottom-container">
        <el-row :gutter="20">
          <el-col :span="4">
            <div class="left-tree">
              <el-input
                placeholder="输入关键字"
                v-model="filterText"
                suffix-icon="el-icon-search"
              >
              </el-input>
              <el-tree
                class="filter-tree"
                :data="treeData"
                :props="defaultProps"
                default-expand-all
                :filter-node-method="filterNode"
                ref="tree"
              >
              </el-tree>
            </div>
          </el-col>
          <el-col :span="20">
            <div style="height: 100%">
              <el-table :data="tableData" border style="width: 100%;" @row-click="handleRowClick">
                <el-table-column prop="signDate" label="签订日期"></el-table-column>
                <el-table-column prop="contractName" label="合同名称" width="260"></el-table-column>
                <el-table-column prop="contractNumber" label="合同编号" width="150"></el-table-column>
                <el-table-column prop="contractFee" label="合同金额"></el-table-column>
                <el-table-column prop="totalFee" label="收付总额"></el-table-column>
                <el-table-column prop="remainingFee" label="剩余余额"></el-table-column>
                <el-table-column prop="facingEachOther" label="相对方" width="250"></el-table-column>
                <el-table-column prop="entryName" label="项目名称" width="150"></el-table-column>
              </el-table>
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                :total="4"
                style="float: right; margin: 20px 0;">
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="60%"
      :close-on-click-modal="false"
      destroy-on-close
      @close="closeModal"
    >
      <payment-contract :title="title" :row="selectedRow" :closeModal="closeModal" :ModalType="ModalType"></payment-contract>
    </el-dialog>
  </div>
</template>

<script>
import paymentContract from './components/paymentContract'
export default {
  name: 'contractRegistration',
  components:{
    paymentContract
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        entryName: '',
        contractName: '',
        contractNumber: '',
        paymentType: undefined,
        facingEachOther: ''
      },
      paymentTypeOptions: [
        { label: '收款', value: '0' },
        { label: '付款', value: '1' }
      ],
      expand: false,
      tableData: [
        {
          signDate: '2023-09-26',
          contractName: '风光一体化防沙治沙',
          contractNumber: 'SKHT2022090201',
          contractFee: '220,000.00',
          totalFee: '65,000.00',
          remainingFee: '155,000.00',
          facingEachOther: '内蒙古林草生态建设有限责任公司',
          entryName: '风光一体化防沙治沙',
          title:'收款合同'
        },
        {
          signDate: '2023-09-26',
          contractName: '三北六期',
          contractNumber: 'SKHT2022090202',
          contractFee: '220,000.00',
          totalFee: '65,000.00',
          remainingFee: '155,000.00',
          facingEachOther: '内蒙古林草生态建设有限责任公司',
          entryName: '三北六期',
          title:'收款合同'
        },
        {
          signDate: '2023-09-26',
          contractName: '蚂蚁森林',
          contractNumber: 'fKHT2022090203',
          contractFee: '220,000.00',
          totalFee: '65,000.00',
          remainingFee: '155,000.00',
          facingEachOther: '内蒙古林草生态建设有限责任公司',
          entryName: '蚂蚁森林',
          title:'付款合同'
        },
        {
          signDate: '2023-09-26',
          contractName: '蓝旗机器人造林',
          contractNumber: 'fKHT2022090204',
          contractFee: '220,000.00',
          totalFee: '65,000.00',
          remainingFee: '155,000.00',
          facingEachOther: '内蒙古林草生态建设有限责任公司',
          entryName: '蓝旗机器人造林',
          title:'付款合同'
        }
      ],
      filterText: '',
      treeData: [{
        id: 1,
        label: '收付类型',
        children: [
          {
            id: 2,
            label: '收款'
          },
          {
            id: 3,
            label: '付款'
          },
          {
            id: 4,
            label: '无'
          }]
      }],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      currentPage: 1,
      dialogVisible:false,
      title:'',
      selectedRow:{},
      ModalType:''
    }
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    }
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      //this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
    },

    toggle() {
      this.expand = !this.expand
    },

    filterNode(value, data) {
      if (!value) return true
      return data.label.indexOf(value) !== -1
    },

    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },

    //关闭弹窗
    closeModal(){
      this.selectedRow = {};
      this.dialogVisible=false
    },

    //点击收款合同/付款合同弹窗
    showModalPage(title){
      this.title = title
      this.selectedRow = {};
      this.ModalType = 'add'
      this.dialogVisible=true
    },

    //点击table行弹窗
    handleRowClick(row, column, event){
      this.title = row.title
      this.selectedRow = row;
      this.ModalType = 'edit'
      this.dialogVisible = true;
    }
  }
}
</script>

<style lang="scss" scoped>
.contract-content {
  background: #ffffff;
  margin-bottom: 16px;
  box-sizing: border-box;
  border-radius: 5px 5px 0 0;
  border: 1px solid #e7eff3;
  box-shadow: 0 0 5px #dde9ef;
}

.card-title {
  color: #11A983;
  border-bottom: 0;
  font-weight: 600;
  font-size: 16px;
  line-height: 25px;
  letter-spacing: 1px;
  width: 100%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  height: 45px;
  padding: 10px 20px 0;
  border-radius: 3px;
}

.contract-card {
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
}

.card-row-container {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 5px 10px;
  border: 1px solid #C2C2C2;
  border-radius: 4px;
  box-sizing: border-box;
  flex-wrap: nowrap;
}

.left-icon {
  height: 100%;
  width: 76px;
  display: -ms-flexbox;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  border-radius: 3px 0px 0px 3px;
}

.bg-blue {
  background-color: #11A983;
  border: 1px solid #11A983;
}

.bg-yellow {
  background-color: rgb(233, 195, 66);
  border: 1px solid rgb(233, 195, 66);
}

.rightTitle {
  width: calc(100% - 76px);
  height: 100%;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-line-pack: center;
  align-content: center;
}

.mainTitle {
  height: 22px;
  width: 100%;
  margin-bottom: 5px;
  padding: 0 14px;
  box-sizing: border-box;
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  color: #000;
  line-height: 22px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.subTitle {
  height: 17px;
  width: 100%;
  padding: 0 14px;
  box-sizing: border-box;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  color: #999;
  line-height: 17px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.top-search {
  padding: 16px 20px;
}

.bottom-container {
  margin-top: 10px;
  padding: 0 20px;

  .left-tree{
    margin-top: 25px;
  }
}
.page-img{
  width: 100%;
}
</style>
